package org.jeecg.demo.wx.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;

import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.demo.wx.dto.ModifyDelayDto;
import org.jeecg.demo.wx.entity.RlDelay;
import org.jeecg.demo.wx.service.IRlDelayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "rl_delay")
@RestController
@RequestMapping("/calendar/rlDelay")
@Slf4j
public class RlDelayController extends JeecgController<RlDelay, IRlDelayService> {
    @Autowired
    private IRlDelayService rlDelayService;

    @AutoLog(value = "请求延期")
    @ApiOperation(value = "请求延期", notes = "请求延期")
    @PostMapping(value = "/approve")
    public Result<String> approveDelay(@RequestParam("scheduleId") Integer scheduleId,
                                       @RequestParam("schedulerId") String schedulerId) {
        rlDelayService.approveDelay(scheduleId, schedulerId);
        return Result.OK("请求成功！");
    }

    @AutoLog(value = "查看当前用户待审批数")
    @ApiOperation(value = "查看当前用户待审批数", notes = "查看当前用户待审批数")
    @PostMapping(value = "/queryDelayNumber")
    public Result<Long> queryDelayNumber(@RequestParam("taskerId") String taskerId) {
        Long number = rlDelayService.queryDelayNumber(taskerId);
        return Result.OK(number);
    }

    @AutoLog(value = "查看用户延期任务审批详情")
    @ApiOperation(value = "查看用户延期任务审批详情", notes = "查看用户延期任务审批详情")
    @PostMapping(value = "/queryDelayList")
    public Result<List<RlDelay>> queryDelayList(@RequestParam("schedulerId") String schedulerId) {
        List<RlDelay> list = rlDelayService.queryDelayList(schedulerId);
        return Result.OK(list);
    }

    @AutoLog(value = "修改审批状态")
    @ApiOperation(value = "修改审批状态", notes = "修改审批状态")
    @PostMapping(value = "/modifyState")
    public Result<String> modifyState(@RequestBody ModifyDelayDto dto) {
        rlDelayService.modifyState(dto);
        return Result.OK("修改成功！");
    }

    @AutoLog(value = "查看当前用户需要审批的任务列表")
    @ApiOperation(value = "查看当前用户需要审批的任务列表", notes = "查看当前用户需要审批的任务列表")
    @PostMapping(value = "queryApproveList")
    public Result<List<RlDelay>> queryApproveList(@RequestParam("taskerId") String taskerId) {
        List<RlDelay> result = rlDelayService.queryApproveList(taskerId);
        return Result.OK(result);
    }
}
